/*
 * CaseGenerator.h
 *
 *  Created on: 29/05/2011
 *      Author: godinho
 */

#ifndef CASEGENERATOR_H_
#define CASEGENERATOR_H_

#include <vector>
#include <controller/Case.h>

namespace localview {
class LocalView;
}

/**
 * Abstract class that defines the interface expected to an object able to
 * generate, through an evolutive algorithm, a list of cases.
 */
class CaseGenerator {
public:

	/**
	 * Start the loop of evolutions to create new cases based on the initial
	 * population.
	 *
	 * Implementations of this method must use an infinite loop, so it is
	 * recommended that this method be called only separated thread. This
	 * method is suppose to return only when is called the method setTimedOut
	 * by some another thread. Then another concern on implementing this class
	 * is to make it thread safe.
	 *
	 * @param initialPopulation A list of cases that will be used as initial
	 * 							population.
	 */
	virtual void startEvolution(std::vector<Case*> initialPopulation, int phaseId) = 0;

	/**
	 * This method returns the last population of evolutive algorithm.
	 *
	 * Must be called only after a startEvolution and setTimedOut.
	 *
	 * @return generated population.
	 */
	virtual std::vector<Case*> getCases() = 0;

	/**
	 * Stops execution of evolutive algorithm.
	 *
	 * The result of algorithm algorithm can be retrieved using
	 * getCases(0
	 */
	virtual void setTimedOut() = 0;

	virtual void setLocalview(localview::LocalView* lv) = 0;
};

#endif /* CASEGENERATOR_H_ */
